/** *****************  JAVA头文件说明  ****************
 * file name  :  DataSourceConfig.java
 * owner      :  xu
 * copyright  :  UMPAY
 * description:  
 * modified   :  2016-11-2
 * *************************************************/ 

package com.jflm.config;

import javax.sql.DataSource;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.PropertySources;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;

import com.alibaba.druid.pool.DruidDataSource;


/** ******************  类说明  *********************
 * class       :  DataSourceConfig
 * @author     :  xuhuafeng
 * @version    :  1.0  
 * description :  dataSource配置
 * ************************************************/
@Configuration
@PropertySources(value={@PropertySource("classpath:jdbc.properties")})
public class DataSourceConfig extends CachingConfigurerSupport {
	
	@Bean
    @ConfigurationProperties(prefix="spring.datasource")
    public DataSource dataSource() {
        return new DruidDataSource();
    }
    
    @Bean
    public PlatformTransactionManager transactionManager() {
        return new DataSourceTransactionManager(dataSource());
    }

}
